package com.bitcat.todoapp.demo.component

import android.os.Bundle
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.bitcat.todoapp.R
import com.bitcat.todoapp.databinding.ActivityToastDemoBinding
import com.bitcat.todoapp.utils.ToastUtil
import es.dmoral.toasty.Toasty

class ToastDemoActivity : AppCompatActivity() {

    private lateinit var binding: ActivityToastDemoBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        binding = ActivityToastDemoBinding.inflate(layoutInflater)
        setContentView(binding.root)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        binding.normalToastBtn.setOnClickListener {
            Toast.makeText(this, "登录成功", Toast.LENGTH_SHORT).show()
        }

        binding.toastyBtn.setOnClickListener {
            Toasty.success(this,"登录成功").show()
        }

        //error
        binding.toastyBtn2.setOnClickListener {
            Toasty.error(this,"登录失败").show()
        }

        //info
        binding.toastyBtn3.setOnClickListener {
            Toasty.info(this,"登录中").show()
        }

        //warning
        binding.toastyBtn4.setOnClickListener {
            Toasty.warning(this,"登录中").show()
        }

        //normal
        binding.toastyBtn5.setOnClickListener {
            Toasty.normal(this,"登录中").show()
        }

        binding.toastyBtn6.setOnClickListener {
            ToastUtil.showToast("登录成功")
        }
    }
}